<?php include './application/views/top.php'; ?>
<script src="/resource/js/circle-progress.js"></script>
<div class="clear h50"></div>
<div class="layout entry">
	<div class="left"><img src="/resource/images/dl_tup.png" width="806" height="429"></div>
	<div class="right">
	<form  method="post" id="login_form">
    <input type="hidden" name="act" value="login">
    <input type="hidden" name="obj_id" id="obj_id" value=""/>
		<div class="user-frame">
			<div class="title">
            	<h2>账户登录</h2>
                <s><a href="/reg/index.html">立即注册</a></s>
            </div>
            <dl>
            	<dt class="width"><h3>帐号：</h3></dt>
                <dd>
                <input required="required" class="input-login" name="phone" type="text" id="username" placeholder="&nbsp;请输入手机号码" onkeydown="if(window.event.keyCode==13){window.event.keyCode=9;}">
                </dd>
			</dl>       
            
			<dl>
            	<dt><h3>密码：</h3></dt>
                <dd>
                <input required="required" class="input-login"  name="password" type="password" id="password" placeholder="&nbsp;请输入密码" onkeydown="if(window.event.keyCode==13){window.event.keyCode=9;}">
                </dd>
		  </dl> 
            
            
           <dl>
           	  <dt><h3 class="yzm">验证码：</h3></dt>
              <dd>
              <input name="captcha" type="text" required="required" class="input-two" id="captcha" placeholder="&nbsp;验证码" onkeydown="if(window.event.keyCode==13){login_submit();}" maxlength="4">
              </dd>
              <i><a href="javascript:void(0);" onclick="changeImage();"><img style="margin-top:8px;margin-left:10px;" id="imgCode" src="/yanzheng" class="fl"></a></i>
              <span onclick="changeImage();" style="cursor:pointer;">换一换</span>
		  </dl> 
            
           <p class="jzyfm">
        		<label for="chekbox">记住用户名</label>
                <input type="checkbox" name="savepwd">
           </p>
           <p class="wjdlmm">
           		<a class="col-red" href="/password/forget.html">忘记登录密码？</a>
           </p>
			<p class="send">
            	<a href="javascript:void();" onclick="login_submit();">立即登录</a>
            </p>
                 
    	</div>
	</form>
	</div>
</div>
<div class="clear h50"></div>
<?php include "./application/views/footer.php";?>
<script type="text/javascript">

$(function () {
	var inp = $('#captcha');
//    inp.click(function(){
//        this.attr({src:"/yanzheng/index/?"+Math.random()});
//    });
});
function clearText(input){
	if(input.value=='用户名/邮箱'){
		input.value="";
	}
}
function setText(input,txt){
	if(input.value==''){
		input.value=txt;
	}
}
function showPwd(){
	$('#pwdtxt').css('display','none');
	$('#password').css('display','');
	$('#password').focus();
}
function showPwdVal(){
	if($('#password').val()==''){
		$('#password').css('display','none');
		$('#pwdtxt').css('display','');	
	}
}

function login_submit(){
	var host = window.location.href;
	var isUrl = host.indexOf('?obj='); 
	if(isUrl != -1) $("#obj_id").val('888');
	var options = {
		url : '/login',
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg==''){
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						location=ret.data.url;
					}
				});
				$("#msg").html("登陆成功<br>3秒后自动跳转"+ret.sycDz);
				//document.write(ret.sycDz);
				setTimeout(function(){location=ret.data.url;},3000);
			}else{
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						document.getElementById("imgCode").src = "/yanzheng/index/?" + Math.random();
					}
				});
				$("#msg").html(ret.msg);
			}
		}
	};
	$("#login_form").ajaxSubmit(options);
	return false;
}

function checkForm(){
	$('#dialog').dialog({
		modal:true,
		title:'系统提示'
	}); 
	$("#msg").html("正在登录...");
	var err = '';
	if($('#username').val()=='' || $('#username').val()=='用户名/邮箱'){
		err = '请输入用户名';
	}else if($('#password').val()=='' || $('#password').val()=='请输入密码'){
		err = '请输入密码';
	}else if($('#captcha').val()==''){
		err = '请输入验证码';
	}
	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
				document.getElementById("imgCode").src = "/yanzheng/index/?" + Math.random();
			}
		}); 
		$("#msg").html(err);
		return false;
	}
}
</script>